home *** CD-ROM | disk | FTP | other *** search
- Path: web.cae.ca!usenet
- From: fraserh@cae.ca (Fraser Hutchinson)
- Newsgroups: comp.lang.c++
- Subject: Re: Binary association problem
- Date: 1 Mar 1996 17:56:05 GMT
- Organization: CAE Electronics Ltd.
- Message-ID: <4h7dnl$qaf@web.cae.ca>
- References: <31296F14.88E@esec.ch> <Dn4Dt3.Kr5@ce.philips.nl>
- NNTP-Posting-Host: pch63.cae.ca
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In article <Dn4Dt3.Kr5@ce.philips.nl>, hartj@ce.philips.nl says...
- >
- >Oliver Plohmann <opl@esec.ch> writes:
- >
- >>Hello,
-
- Hello
-
- >
- >>I habe two classes that reference each other. I put those classes into
- >>one header to get the code linked. Due to the nature of my application I
- >>have now several class associated with each eather in one header. My
- >>compiler can't handle it any more and creates a fatal error. I could
- >>switch compiler but every compiler has some problem. I think it would
- >>only mean substituting problems for other problems.
-
- This should not be a problem at all.
- [deleted]
-
- >>Thank you, Olli Plohmann
- >
- >>-------------------------a.h------------------------
- >
- >>class B;
- >
- >>class A {
- >
- >> int* x;
- >>public:
- >
- >> A() {};
- >> ~A() {};
- >
- >> void operator+(const int& i) {
- >
- >> *x=i; // protection violation !
- >
- >OOPS?! Where is 'x' supposed to point to?
-
- Well, this is secondary - should still compile and just corrupt memory at
- runtime.
-
- The real problem I suspect, is that the compiler sees you setting a reference
- to a const and says "oops! you cannot do that!" - consts are supposed to be
- read only and, (correct me if I am wrong, I am not near a reference source),
- will not compile if you try to 'sneak around' the const this way. If the
- compiler let you do this, it might well let you modify the value of *x, thus
- indirectly modifying a const.
-
- Of course, I may be wrong :)
-
-
- Fraser
-
-
-
-
-